﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bank
{
    class Mortgage : Account
    {
        public Mortgage(Customer customer, double balance, double interestRate)
            : base(customer, balance, interestRate)
        {
        }

        public override double CalculateInterest(int months)
        {
            if (this.Customer is Company)
            {
                if (months <= 12)
                {
                    return (base.CalculateInterest(months) / 2);
                }
                else
                {
                    return ((base.CalculateInterest(months) / 2) + (base.CalculateInterest(months - 12)));
                }
            }
            else if (this.Customer is Individual)
            {
                if (months <= 6)
                {
                    return 0;
                }
                else
                {
                    return base.CalculateInterest(months - 6);
                }
            }
            else
            {
                return 0;
            }
        }
    }
}
